#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

int main(int argc, char const *argv[])
{
    FILE *fp;
    int i = 0;
    char filename[100] = {0}; 
    while (1)
    {
        sprintf(filename,"file%d",i);
        printf("filename=%s\n",filename);
        fp = fopen(filename,"w");
        if (fp == NULL)
        {
            perror("fopen");
            exit(-1);
        }
        i++;
    }
    
    return 0;
}